import com.google.protobuf.StringValue;
import org.junit.Test;

import java.io.UnsupportedEncodingException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;

public class LocalServiceImpl {

    @Test
    public void testHost() throws UnknownHostException {
        System.out.println(InetAddress.getLocalHost().getHostAddress());
    }

    @Test
    public void testPrint() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException {
        Class classType = Class.forName("com.service.ServiceImpl");
        Constructor constructor = classType.getConstructor();
        Class parameterType = Class.forName("java.lang.String");
        Class[] parameterTypes = new Class[]{parameterType};
        Object[] parameterValues = new Object[1];
        for(int i=0;i<1;i++){
            parameterValues[i] = StringValue.newBuilder().build();
        }
        classType.getMethod("printString",parameterTypes).invoke(constructor.newInstance(),parameterValues);
    }

    @Test
    public void testSerialize() throws UnsupportedEncodingException {
        System.out.println("a".getBytes("UTF-8").equals("a".getBytes("UTF-8")));
        System.out.println("a".getBytes(StandardCharsets.UTF_8).equals("a".getBytes("UTF-8")));
        System.out.println("a".getBytes(StandardCharsets.US_ASCII).equals("a".getBytes("UTF-8")));
    }

}
